@extends('admin/layout')

@section('content')
    <script>
        function del()
        {
            if(confirm("确定要删除吗？"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    </script>
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li class="active">自助订单列表</li>
            </ol>
            <div class="input-group margin">
                <div style="float: left">
                    <form action="{{ url('admin/orders1') }}" method="post" >
                        {{ csrf_field() }}
                        <div style="float: left">
                            <select style="width: 150px" id="sel" onchange="select()" name="searchtype" class="form-control">
                                @foreach($searchtype as $value)
                                    <option value="{{ $value['id'] }}">{{ $value['searchtype'] }}</option>
                                @endforeach
                            </select>
                        </div>
                        <script>
                            function select() {
                                var val = $('#sel option:selected').val();
                                if(val == 2) {
                                    $('#form').html('<input style="width: 200px" id="data" name="param" type="text" class="form-control" onClick="laydate({istime: true, format: \'YYYY-MM-DD\'})">');
                                }
                                else{
                                    $('#form').html('<input style="width: 200px" id="data" name="param" type="text" class="form-control">');
                                }
                            }
                            //                       </script>
                        <div style="float: left" id="form">
                            <input style="width: 200px"  name="param" type="text" class="form-control">
                        </div>
                        <div style="float: left">
                            <input  type="submit" class="btn btn-info btn-flat" value="Go!">
                        </div>
                    </form>
                </div>
            </div>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12" style="width: 100%;">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">内容</h3>
                        </div>
                        <span id="msg" style="display: none">
                            @if (count($errors) > 0)
                                @foreach ($errors->all() as $error)
                                    <div style="width: 100%;">
                                        <span style="color: red;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ $error }}</span>
                                    </div>
                                @endforeach
                            @else
                                <div style="width: 100%;">
                                    <span style="color: green;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ Session::get('msg') }}</span>
                                </div>
                            @endif
                        </span>
                        <script type="text/javascript">
                            var _msg = $('#msg div span').text();
                            console.log(_msg);
                            if(_msg != ''){
                                layer.msg(_msg);
                            }
                        </script>
                        <div class="box-body" style="overflow: auto;">
                            <table class="table table-striped table-hover text-center">
                                <tr>
                                    {{--@foreach($searchtype as $value)--}}
                                        {{--<th style="width: 50px; text-align:center">{{ $value['searchtype'] }}</th>--}}
                                    {{--@endforeach--}}
                                    <th style="width: 50px; text-align:center;min-width: 75px;">编号</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">创建时间</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">订单编号</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">商品名称</th>
                                    <th style="width: 50px; text-align:center;min-width: 55px;">商品数量</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">订单总价</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">客户名称</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">领取方式</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">订单地址</th>
                                    <th style="width: 50px; text-align:center;min-width: 75px;">收件人电话</th>
                                    @if(Session::get('roleid') !=1)
                                        <th style="width: 50px; text-align:center;min-width: 75px;">兑换码</th>
                                    @else
                                        <th style="width: 50px; text-align:center;min-width: 75px;">兑换人</th>
                                    @endif
                                    {{--<th style="width: 50px; text-align:center;min-width: 75px;">批次号</th>--}}
                                    <th style="width: 50px; text-align:center;min-width: 80px;">操作</th>
                                </tr>
                                @foreach($list['data'] as $value)
                                    <tr>
                                        <td>{{ $value['id'] }}</td>
                                        <td>{{ $value['create_time'] }}</td>
                                        <td>{{ $value['order_id'] }}</td>
                                        {{--<td>{{ $value['goods_name'] }}</td>--}}
                                        <td>{{ App\Goods::find($value['goods_id'])['goods_name'] }}</td>
                                        <td>{{ $value['goods_num'] }}</td>
                                        <td>{{ $value['total_price'] }}</td>
                                        {{--<td>{{ $value['user_name'] }}</td>--}}
                                        <td>{{ App\Users::find($value['user_id'])['name'] }}</td>
                                        <td>
                                            @if($value['get_way'] ==1)自取
                                            @elseif($value['get_way'] ==2)邮寄
                                            @endif
                                        </td>
                                        <td>{{ App\Users::find($value['user_id'])['address'] }}</td>
                                        <td>{{ App\Users::find($value['user_id'])['phone'] }}</td>
                                        @if(Session::Get('roleid') !=1 )
                                            <td>{{ $value['code'] }}</td>
                                        @else
                                            <td>{{ App\Manage::find($value['change_id'])['username'] }}</td>
                                        @endif
                                        {{--<td>--}}
                                            {{--{{ $value['batch'] }}--}}
                                        {{--</td>--}}
                                        <td>
                                            @if($value['status'] == 0)
                                                <a class="btn btn-success btn-xs"  href="{{ url('admin/orders/oneStatus/'.$value['id'].'/1' )}}" >未兑换<a>
                                            @else
                                                <a class="btn btn-default btn-xs" >已兑换<a>
                                            @endif
                                            @if(Session::get('roleid') ==1)
                                                @if($value['audit'] == 0)
                                                    <a class="btn btn-success btn-xs"  href="{{ url('admin/orders/setAudit/'.$value['id'].'/1' )}}" >未审核<a>
                                                @else
                                                    <a class="btn btn-default btn-xs" >已审核<a>
                                                @endif
                                            @endif
                                            <a class="btn btn-warning btn-xs"  href="{{ url('admin/orderList/'.$value['id']) }}" >查看<a>
                                        </td>
                                    </tr>
                                @endforeach
                            </table>
                        </div>
                        <div calss="pages" style="text-align: center;">
                            <div style="margin: auto;">{{ $ord->links() }}</div>
                        </div>
                        <!-- /.box -->
                    </div>
                    <!-- /.row -->
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <script type="text/javascript" src="{{ asset('client/js/laydate.js') }}"></script>
    <!-- /.content-wrapper -->
@stop